<template>
  <c-view>
    <template v-slot:header>
      <div class="title">
        {{ $route.meta.title }}
        <!-- <el-button type="primary" :size="size" icon="el-icon-plus" @click="showDialog">新增</el-button> -->
      </div>
    </template>
    <div class="main__box">
      <c-table
        ref="cTable"
        selection
        hasBorder
        :size="size"
        :max-height="730"
        :loading="isLoading"
        :table-header="tableHeader"
        :table-list="tableList"
        :page-info="pageInfo"
        :table-inner-btns="tableInnerBtns"
        @change-pagination="changePagination"
      >
        <template v-slot:header>
          <c-search :form-model="searchObj" :form-items="searchItems" @submit-form="searchSubmit" @reset-form="searchReset"></c-search>
        </template>
      </c-table>
    </div>
    <!-- <div v-if="dialogObj.isShow">
      <c-dialog class="dialog-box" :is-show="dialogObj.isShow" :title="dialogObj.title" close-btn @before-close="dialogObj.isShow = false" @on-submit="dialogConfirm">
        <enum-add ref="childRef" :init-data.sync="dialogObj.initData" :is-edit="dialogObj.isEdit"></enum-add>
      </c-dialog>
    </div> -->
  </c-view>
</template>
<script>
import mixinTable from 'mixins/table'
// import CDialog from 'components/dialog'

export default {
  name: 'dictList',
  mixins: [mixinTable],
  components: {
    // CDialog
  },
  data() {
    return {
      tableInnerBtns: [],
      tableHeader: [
        {
          label: '字典编码',
          prop: 'dicCode',
          search: {
            type: 'input'
          }
        },
        {
          label: '字典名称',
          prop: 'name'
        },
        {
          label: '字典id',
          prop: 'dicId'
        },
        {
          label: '编码',
          prop: 'code'
        },
        {
          label: '创建时间',
          prop: 'createTime',
          width: 160
        },
        {
          label: '创建者',
          prop: 'createUser'
        }
      ]
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      const { pageNo, pageSize } = this.pageInfo
      const { dateTime, ...other } = this.searchObj
      const searchDate = this.getSearchDate(dateTime)
      this.isLoading = true
      this.$api.settings
        .fetch('sysDic', {
          ...searchDate,
          ...other,
          rows: pageNo,
          offset: pageSize
        })
        .then(res => {
          this.isLoading = false
          if (res && res.totalCount) {
            const { data, totalCount } = res
            this.pageInfo.totalNum = totalCount
            this.tableList = data
          } else {
            this.tableList = res
          }
        })
    }
  }
}
</script>
<style lang="less" scoped>
.title {
  display: flex;
  justify-content: space-between;
  width: 100%;
}
</style>
